export default {
  namespaced: true, // 开启命名空间
  state: {
    // 存放状态
    tagsList:
      localStorage.getItem("tagsList") !== ""
        ? JSON.parse(localStorage.getItem("tagsList"))
        : [],
  },
  getters: {
    // 计算属性
  },
  mutations: {
    // 定义修改状态的方法
    setTagsList(state, value) {
      state.tagsList = value;
      localStorage.setItem("tagsList", JSON.stringify(value));
    },
  },
  actions: {
    // 定义异步方法
    updateTagsList({ commit }) {
      commit("setTagsList", [
        { id: 1, title: "Vue", backgroundColor: "brown" },
        { id: 2, title: "React", backgroundColor: "orange" },
        { id: 3, title: "Axios", backgroundColor: "blue" },
        { id: 4, title: "正则", backgroundColor: "purple" },
        { id: 5, title: "拖拽", backgroundColor: "blue" },
        { id: 6, title: "测", backgroundColor: "red" },
        { id: 7, title: "试", backgroundColor: "black" },
        { id: 8, title: "antd", backgroundColor: "violet" },
        { id: 9, title: "正则", backgroundColor: "green" },
        { id: 10, title: "表达式", backgroundColor: "teal" },
      ]);
    },
  },
};
